Skip to content

Elide template in repr for Layout objects #1582

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 27, 2019
Merged

Conversation

jonmmease
Copy link
Contributor

When displaying go.Figure and go.Layout with __repr__, elide the representation of layout.template.

Display Figure

import plotly.graph_objs as go

fig = go.Figure(
    data=[go.Scatter(y=[2, 1, 3])],
    layout={'xaxis': {'range': [-1, 4]},
            'template': 'plotly'}
)
fig
Figure({
    'data': [{'type': 'scatter', 'uid': 'e783f9bc-fb40-4fde-b89a-f5d16e83653b', 'y': [2, 1, 3]}],
    'layout': {'template': '...', 'xaxis': {'range': [-1, 4]}}
})

Display Layout

print(fig.layout)
Layout({
    'template': '...', 'xaxis': {'range': [-1, 4]}
})

Display Template

print(fig.layout.template)
layout.Template({
    'data': {'bar': [{'marker': {'line': {'color': '#E5ECF6', 'width': 0.5}}, 'type': 'bar'}],
             'barpolar': [{'marker': {'line': {'color': '#E5ECF6', 'width': 0.5}}, 'type': 'barpolar'}],
             'carpet': [{'aaxis': {'endlinecolor': '#2a3f5f',
                                   'gridcolor': 'white',
                                   'linecolor': 'white',
                                   'minorgridcolor': 'white',
                                   'startlinecolor': '#2a3f5f'},
                         'baxis': {'endlinecolor': '#2a3f5f',
                                   'gridcolor': 'white',
                                   'linecolor': 'white',
                                   'minorgridcolor': 'white',
                                   'startlinecolor': '#2a3f5f'},
                         'type': 'carpet'}],
             'choropleth': [{'colorbar': {'outlinewidth': 0, 'ticks': ''}, 'type': 'choropleth'}],
             'contour': [{'colorbar': {'outlinewidth': 0, 'ticks': ''},
                          'colorscale': [[0.0, '#0508b8'], [0.0893854748603352,
                                         '#1910d8'], [0.1787709497206704,
                                         '#3c19f0'], [0.2681564245810056,
                                         '#6b1cfb'], [0.3575418994413408,
                                         '#981cfd'], [0.44692737430167595,
                                         '#bf1cfd'], [0.5363128491620112,
                                         '#dd2bfd'], [0.6256983240223464,
                                         '#f246fe'], [0.7150837988826816,
                                         '#fc67fd'], [0.8044692737430168,
                                         '#fe88fc'], [0.8938547486033519,
                                         '#fea5fd'], [0.9832402234636871,
                                         '#febefe'], [1.0, '#fec3fe']],
                          'type': 'contour'}],
             'contourcarpet': [{'colorbar': {'outlinewidth': 0, 'ticks': ''}, 'type': 'contourcarpet'}],
             'heatmap': [{'colorbar': {'outlinewidth': 0, 'ticks': ''},
                          'colorscale': [[0.0, '#0508b8'], [0.0893854748603352,
                                         '#1910d8'], [0.1787709497206704,
                                         '#3c19f0'], [0.2681564245810056,
                                         '#6b1cfb'], [0.3575418994413408,
                                         '#981cfd'], [0.44692737430167595,
                                         '#bf1cfd'], [0.5363128491620112,
                                         '#dd2bfd'], [0.6256983240223464,
                                         '#f246fe'], [0.7150837988826816,
                                         '#fc67fd'], [0.8044692737430168,
                                         '#fe88fc'], [0.8938547486033519,
                                         '#fea5fd'], [0.9832402234636871,
                                         '#febefe'], [1.0, '#fec3fe']],
                          'type': 'heatmap'}],
             'heatmapgl': [{'colorbar': {'outlinewidth': 0, 'ticks': ''}, 'type': 'heatmapgl'}],
             'histogram': [{'marker': {'colorbar': {'outlinewidth': 0, 'ticks': ''}}, 'type': 'histogram'}],
             'histogram2d': [{'colorbar': {'outlinewidth': 0, 'ticks': ''},
                              'colorscale': [[0.0, '#0508b8'],
                                             [0.0893854748603352, '#1910d8'],
                                             [0.1787709497206704, '#3c19f0'],
                                             [0.2681564245810056, '#6b1cfb'],
                                             [0.3575418994413408, '#981cfd'],
                                             [0.44692737430167595, '#bf1cfd'],
                                             [0.5363128491620112, '#dd2bfd'],
                                             [0.6256983240223464, '#f246fe'],
                                             [0.7150837988826816, '#fc67fd'],
                                             [0.8044692737430168, '#fe88fc'],
                                             [0.8938547486033519, '#fea5fd'],
                                             [0.9832402234636871, '#febefe'], [1.0,
                                             '#fec3fe']],
                              'type': 'histogram2d'}],
             'histogram2dcontour': [{'colorbar': {'outlinewidth': 0, 'ticks': ''},
                                     'colorscale': [[0.0, '#0508b8'],
                                                    [0.0893854748603352,
                                                    '#1910d8'],
                                                    [0.1787709497206704,
                                                    '#3c19f0'],
                                                    [0.2681564245810056,
                                                    '#6b1cfb'],
                                                    [0.3575418994413408,
                                                    '#981cfd'],
                                                    [0.44692737430167595,
                                                    '#bf1cfd'],
                                                    [0.5363128491620112,
                                                    '#dd2bfd'],
                                                    [0.6256983240223464,
                                                    '#f246fe'],
                                                    [0.7150837988826816,
                                                    '#fc67fd'],
                                                    [0.8044692737430168,
                                                    '#fe88fc'],
                                                    [0.8938547486033519,
                                                    '#fea5fd'],
                                                    [0.9832402234636871,
                                                    '#febefe'], [1.0, '#fec3fe']],
                                     'type': 'histogram2dcontour'}],
             'mesh3d': [{'colorbar': {'outlinewidth': 0, 'ticks': ''}, 'type': 'mesh3d'}],
             'parcoords': [{'line': {'colorbar': {'outlinewidth': 0, 'ticks': ''}}, 'type': 'parcoords'}],
             'scatter': [{'marker': {'colorbar': {'outlinewidth': 0, 'ticks': ''}}, 'type': 'scatter'}],
             'scatter3d': [{'marker': {'colorbar': {'outlinewidth': 0, 'ticks': ''}}, 'type': 'scatter3d'}],
             'scattercarpet': [{'marker': {'colorbar': {'outlinewidth': 0, 'ticks': ''}}, 'type': 'scattercarpet'}],
             'scattergeo': [{'marker': {'colorbar': {'outlinewidth': 0, 'ticks': ''}}, 'type': 'scattergeo'}],
             'scattergl': [{'marker': {'colorbar': {'outlinewidth': 0, 'ticks': ''}}, 'type': 'scattergl'}],
             'scattermapbox': [{'marker': {'colorbar': {'outlinewidth': 0, 'ticks': ''}}, 'type': 'scattermapbox'}],
             'scatterpolar': [{'marker': {'colorbar': {'outlinewidth': 0, 'ticks': ''}}, 'type': 'scatterpolar'}],
             'scatterpolargl': [{'marker': {'colorbar': {'outlinewidth': 0, 'ticks': ''}}, 'type': 'scatterpolargl'}],
             'scatterternary': [{'marker': {'colorbar': {'outlinewidth': 0, 'ticks': ''}}, 'type': 'scatterternary'}],
             'surface': [{'colorbar': {'outlinewidth': 0, 'ticks': ''}, 'type': 'surface'}],
             'table': [{'cells': {'fill': {'color': '#EBF0F8'}, 'line': {'color': 'white'}},
                        'header': {'fill': {'color': '#C8D4E3'}, 'line': {'color': 'white'}},
                        'type': 'table'}]},
    'layout': {'annotationdefaults': {'arrowcolor': '#506784', 'arrowhead': 0, 'arrowwidth': 1},
               'colorscale': {'diverging': [[0, '#8e0152'], [0.1, '#c51b7d'],
                                            [0.2, '#de77ae'], [0.3, '#f1b6da'],
                                            [0.4, '#fde0ef'], [0.5, '#f7f7f7'],
                                            [0.6, '#e6f5d0'], [0.7, '#b8e186'],
                                            [0.8, '#7fbc41'], [0.9, '#4d9221'], [1,
                                            '#276419']],
                              'sequential': [[0.0, '#0508b8'],
                                             [0.0893854748603352, '#1910d8'],
                                             [0.1787709497206704, '#3c19f0'],
                                             [0.2681564245810056, '#6b1cfb'],
                                             [0.3575418994413408, '#981cfd'],
                                             [0.44692737430167595, '#bf1cfd'],
                                             [0.5363128491620112, '#dd2bfd'],
                                             [0.6256983240223464, '#f246fe'],
                                             [0.7150837988826816, '#fc67fd'],
                                             [0.8044692737430168, '#fe88fc'],
                                             [0.8938547486033519, '#fea5fd'],
                                             [0.9832402234636871, '#febefe'], [1.0,
                                             '#fec3fe']],
                              'sequentialminus': [[0.0, '#0508b8'],
                                                  [0.0893854748603352, '#1910d8'],
                                                  [0.1787709497206704, '#3c19f0'],
                                                  [0.2681564245810056, '#6b1cfb'],
                                                  [0.3575418994413408, '#981cfd'],
                                                  [0.44692737430167595, '#bf1cfd'],
                                                  [0.5363128491620112, '#dd2bfd'],
                                                  [0.6256983240223464, '#f246fe'],
                                                  [0.7150837988826816, '#fc67fd'],
                                                  [0.8044692737430168, '#fe88fc'],
                                                  [0.8938547486033519, '#fea5fd'],
                                                  [0.9832402234636871, '#febefe'],
                                                  [1.0, '#fec3fe']]},
               'colorway': [#636efa, #EF553B, #00cc96, #ab63fa, #19d3f3, #e763fa,
                            #FECB52, #FFA15A, #FF6692, #B6E880],
               'font': {'color': '#2a3f5f'},
               'geo': {'bgcolor': 'white',
                       'lakecolor': 'white',
                       'landcolor': '#E5ECF6',
                       'showlakes': True,
                       'showland': True,
                       'subunitcolor': 'white'},
               'hoverlabel': {'align': 'left'},
               'hovermode': 'closest',
               'mapbox': {'style': 'light'},
               'paper_bgcolor': 'white',
               'plot_bgcolor': '#E5ECF6',
               'polar': {'angularaxis': {'gridcolor': 'white', 'linecolor': 'white', 'ticks': ''},
                         'bgcolor': '#E5ECF6',
                         'radialaxis': {'gridcolor': 'white', 'linecolor': 'white', 'ticks': ''}},
               'scene': {'xaxis': {'backgroundcolor': '#E5ECF6',
                                   'gridcolor': 'white',
                                   'gridwidth': 2,
                                   'linecolor': 'white',
                                   'showbackground': True,
                                   'ticks': '',
                                   'zerolinecolor': 'white'},
                         'yaxis': {'backgroundcolor': '#E5ECF6',
                                   'gridcolor': 'white',
                                   'gridwidth': 2,
                                   'linecolor': 'white',
                                   'showbackground': True,
                                   'ticks': '',
                                   'zerolinecolor': 'white'},
                         'zaxis': {'backgroundcolor': '#E5ECF6',
                                   'gridcolor': 'white',
                                   'gridwidth': 2,
                                   'linecolor': 'white',
                                   'showbackground': True,
                                   'ticks': '',
                                   'zerolinecolor': 'white'}},
               'shapedefaults': {'fillcolor': '#506784', 'line': {'width': 0}, 'opacity': 0.4},
               'ternary': {'aaxis': {'gridcolor': 'white', 'linecolor': 'white', 'ticks': ''},
                           'baxis': {'gridcolor': 'white', 'linecolor': 'white', 'ticks': ''},
                           'bgcolor': '#E5ECF6',
                           'caxis': {'gridcolor': 'white', 'linecolor': 'white', 'ticks': ''}},
               'title': {'x': 0.05},
               'xaxis': {'automargin': True,
                         'gridcolor': 'white',
                         'linecolor': 'white',
                         'ticks': '',
                         'zerolinecolor': 'white',
                         'zerolinewidth': 2},
               'yaxis': {'automargin': True,
                         'gridcolor': 'white',
                         'linecolor': 'white',
                         'ticks': '',
                         'zerolinecolor': 'white',
                         'zerolinewidth': 2}}
})

@jonmmease jonmmease added this to the v3.10 milestone May 27, 2019
@jonmmease jonmmease merged commit 870de12 into master May 27, 2019
@nicolaskruchten nicolaskruchten deleted the enh_repr_updates branch June 19, 2020 16:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant